<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
        <script src="../../dist/vue.js"></script>
    </head>
    <body>
        <div id="app">
            <input v-focue v-if="show" type="text" placeholder="打开页面聚焦" />
            <button @click="show=!show">切换</button>

            <div class="menu" @click="truesecondMenu=!truesecondMenu">菜单</div>
            <ul class="list" v-show="truesecondMenu">
                <li>菜单一</li>
                <li>菜单二</li>
                <li>菜单三</li>
                <li>菜单四</li>
            </ul>
        </div>
        <script>
            Vue.directive('focue', {
                bind: (el, binding, vnode, oldVnode) => {
                    console.log('bind');
                    console.log('el', el);
                    console.log('binding', binding);
                    console.log('vnode', vnode);
                    console.log('oldVnode', oldVnode);
                },
                inserted: el => {
                    el.focus();
                    console.log('inserted');
                },
                update: () => {
                    console.log('update');
                },
                componentUpdated: () => {
                    console.log('componentUpdated');
                },
                unbind: () => {
                    console.log('unbind');
                }
            });
            let vue = new Vue({
                el: '#app',
                data() {
                    return {
                        show: true,
                        truesecondMenu: false
                    };
                }
            });
        </script>
    </body>
</html>
